<?
function banner_spacer($target)
{
if ($target == 'konkurs_left' || $target == 'right' || $target == 'left' || $target=='chat_left' )
return '<div style="margin-bottom: 10px;"></div>';
else return '';
}

function banner($target)
    {
    $out="<div style='position:relative;'>";
    if ($target != 'right' && $target != 'chat_left' && $target != 'konkurs_left')
        $limit = 1; // справа много может быть баннеров
    else
        $limit = 5;

    $z = mysql_query("select * from `banners` where `target`='$target' AND `show`='1' limit $limit");
    // echo "select * from `banners` where `target`='$target' AND `show`='1' limit $limit";
    if (mysql_num_rows($z) != 0)
        while ($t = mysql_fetch_assoc($z))
            {
            // если не флеш, то просто картинка
           // $t['w']=120;$t['h']=60;
            if ($t["ext"] != 'swf')
                {
                $out.=banner_spacer($target);// пробел между баннерами
               $out.=adm_message('banners', $t['id']);
                if ($limit >= 2)
                    $out .='<br />';
                // если есть ссылка, добавляем
                if (!empty($t['link'])) $out .= '<a style="text-decoration: none;" rel="nofollow" target="_BLANK" href="' . $t['link'] . '">
<img src="/images/rrr/' . $t['name'] . '.' . $t['ext'] . '" alt="' . $t['title'] . '" title="' . $t['title'] . '" width="' . $t['w'] . '" height="' . $t['h'] . '" />
</a>';
                else $out .= '<img src="/images/rrr/' . $t['name'] . '.' . $t['ext'] . '" alt="' . $t['title'] . '" title="' . $t['title'] . '" width="' . $t['w'] . '" height="' . $t['h'] . '" />';

                } else  {
                        $out.=banner_spacer($target);// пробел между баннерами
                        $out.=adm_message('banners', $t['id']);
                        $out .= '<span id="banner_'.$t['name'].'"><img src="/images/rrr/'.$t['name'].'.jpg"></span><script type="text/javascript">
/*var so = new swfobject("/images/rrr/'.$t['name'].'.swf","banner_'.$t['name'].'","'.$t['w'].'","'.$t['h'].'","8","#ffffff");
so.write("banner_'.$t['name'].'");*/
var flashvars = {};
var params = {"wmode":"opaque"};
var attributes = {};
swfobject.embedSWF("/images/rrr/'.$t['name'].'.swf", "banner_'.$t['name'].'", "'.$t['w'].'", "'.$t['h'].'", "9.0.0","",flashvars, params, attributes);

</script>';
                        }
            }
    //elseif(_checkuseradmin()==1) $out = adm_message('banners',0);
    return $out.'</div>';
}


function adm_message($type,$id){
    if ($_SESSION['level']>5) $out = '<a style="position:absolute; left:0px; top:0px;" href="/ADM/edit/'.$id.'/?vid='.$type.'">ред.</a>';
return $out;
    
}
?>